package pack;

import java.io.Serializable;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import dao.BiletDAORemote;
import dao.EmployeeDAORemote;
import dto.BiletDTO;
import dto.EmployeeDTO;


@ManagedBean(name = "adminBean")
@RequestScoped
public class AdminBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@EJB
	EmployeeDAORemote employeeDAO;
	
	@EJB
	BiletDAORemote biletDAO;
	
	@ManagedProperty(value = "#{employeeDTO}")
	private EmployeeDTO employeeDTO; // = new EmployeeDTO();
	
	

	@ManagedProperty(value = "#{biletDTO}")
	private BiletDTO biletDTO;
	
	

	FacesContext fc = FacesContext.getCurrentInstance();
	
	private String optiune;
	
	public String angajati(){
		if (getOptiune().equals("Create"))
			return "angajatiCreate.xhtml";
		if (getOptiune().equals("Read"))
			return "angajatiRead.xhtml";
		return "angajatiDelete";
	}
	
	public String carti(){
		if (getOptiune().equals("Create"))
			return "cartiCreate.xhtml";
		if (getOptiune().equals("Read"))
			return "cartiRead.xhtml";
		return "cartiDelete";
	}
	
	public String chestionare(){
		if (getOptiune().equals("Create"))
			return "chestionareCreate.xhtml";
		if (getOptiune().equals("Read"))
			return "chestionareRead.xhtml";
		return "chestionareDelete";
	}
	
	
	public String logOut(){
		fc.getExternalContext().getSessionMap().clear();
		return "home.xhtml";
	}
	
	public String cereri(){
		return "lista.xhtml";
	}

	public String getOptiune() {
		return optiune;
	}

	public void setOptiune(String optiune) {
		this.optiune = optiune;
	}

	public EmployeeDTO getEmployeeDTO() {
		return employeeDTO;
	}

	public void setEmployeeDTO(EmployeeDTO employeeDTO) {
		this.employeeDTO = employeeDTO;
	}
	
	public BiletDTO getBiletDTO() {
		return biletDTO;
	}

	public void setBiletDTO(BiletDTO biletDTO) {
		this.biletDTO = biletDTO;
	}
}
